﻿using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using CodeCrawler.UI.Forms.ChildForms;

namespace CodeCrawler.UI.Forms {
    public partial class ParentForm : Form {
        private int childFormNumber;


        public ParentForm() {
            InitializeComponent();
        }


        /// <summary>
        /// Open File
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenFile(object sender, EventArgs e) {
            var openFileDialog = new OpenFileDialog();
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            openFileDialog.Filter = "C# Source Code files (*.cs)|*.cs|VB.NET Files (*.vb)|*.*|Java Files (*.java)|*.java|All Files (*.*)|*.*";
            if (openFileDialog.ShowDialog(this) == DialogResult.OK) {
                string FileName = openFileDialog.FileName;


                var newSingleFileScanForm = new SingleFileScan(FileName);
                newSingleFileScanForm.MdiParent = this;
                newSingleFileScanForm.Location = new Point(5, 5);
                newSingleFileScanForm.Show();
            }
        }


        /// <summary>
        /// Close OWASP Code Crawler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e) {
            Close();
        }


        /// <summary>
        /// Open Visual Studio Solution
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void vSNETSolutionToolStripMenuItem_Click(object sender, EventArgs e) {
            var form_VisualStudioSolution = new VisualStudioSolution();
            form_VisualStudioSolution.MdiParent = this;
            form_VisualStudioSolution.Show();
        }


        /// <summary>
        /// Open ViewState decoder a base64 string decoder
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void viewstateDecoderToolStripMenuItem_Click(object sender, EventArgs e) {
            var decoder = new ViewStateDecoder();
            decoder.MdiParent = this;
            decoder.SetDesktopLocation(100, 200);
            decoder.Show();
        }


        /// <summary>
        /// Open Dread Calculator Utility
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dreadCalculatorToolStripMenuItem_Click(object sender, EventArgs e) {
            var dreadCalculatorForm = new DreadCalculator();
            dreadCalculatorForm.MdiParent = this;
            dreadCalculatorForm.SetDesktopLocation(100, 200);
            dreadCalculatorForm.Show();
        }


        /// <summary>
        /// OWASP.ORG
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://www.owasp.org");
        }


        /// <summary>
        /// SUN Security Guidelines
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void secureCodingToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://java.sun.com/security/seccodeguide.html");
        }

        #region MDI Form Visualisation
        private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e) {
            statusStrip.Visible = statusBarToolStripMenuItem.Checked;
        }


        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e) {
            LayoutMdi(MdiLayout.Cascade);
        }


        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e) {
            LayoutMdi(MdiLayout.TileVertical);
        }


        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e) {
            LayoutMdi(MdiLayout.TileHorizontal);
        }


        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e) {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }


        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e) {
            foreach (Form childForm in MdiChildren) {
                childForm.Close();
            }
        }
        #endregion

        #region OWASP LINKS
        private void topTenToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project");
        }


        private void webGoatToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://www.owasp.org/index.php/Category:OWASP_WebGoat_Project");
        }


        private void webScarabToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://www.owasp.org/index.php/Category:OWASP_WebScarab_Project");
        }


        private void eSAPIToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API");
        }


        private void aSVSToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start(
                "http://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project");
        }


        private void antiSamyToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project");
        }


        private void developmentGuideToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://www.owasp.org/index.php/Category:OWASP_Guide_Project");
        }


        private void codeReviewGuideToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://www.owasp.org/index.php/OWASP_Code_Review_Guide_Table_of_Contents");
        }


        private void testingGuidesToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://www.owasp.org/index.php/Category:OWASP_Testing_Project");
        }


        private void sAMMToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model");
        }
        #endregion

        #region The WASC Threat Classification
        private void abuseOfFunctionalityToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Abuse-of-Functionality");
        }


        private void bruteForceToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Brute-Force");
        }


        private void bufferOverflowToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Buffer-Overflow");
        }


        private void contentSpoofingToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Content-Spoofing");
        }


        private void credentialSessionPredictionToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Credential-and-Session-Prediction");
        }


        private void crossSiteScriptingToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Cross-Site+Scripting");
        }


        private void crossSiteRequestForgeryToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Cross-Site-Request-Forgery");
        }


        private void denialOfServiceToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Denial-of-Service");
        }


        private void fingerprintingToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Fingerprinting");
        }


        private void formatStringToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Format-String");
        }


        private void hTTPRequestSmugglingToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/HTTP-Response-Smuggling");
        }


        private void hTTPResponseSplittingToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/HTTP-Response-Splitting");
        }


        private void hTTPRequestSmugglingToolStripMenuItem1_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/HTTP-Request-Smuggling");
        }


        private void hTTPRequestSplittingToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/HTTP-Request-Splitting");
        }


        private void integerOverflowsToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Integer-Overflows");
        }


        private void lDAPInjectionToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/LDAP-Injection");
        }


        private void mailCommandInjectionToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Mail-Command-Injection");
        }


        private void nullByteInjectionToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Null-Byte-Injection");
        }


        private void oSCommandingToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/OS-Commanding");
        }


        private void pathTraversalToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Path-Traversal");
        }


        private void predictableResourceLocationToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Predictable-Resource-Location");
        }


        private void remoteFileInclusionToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Remote-File-Inclusion");
        }


        private void routingDetorToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Routing-Detour");
        }


        private void sessionFixationToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Session-Fixation");
        }


        private void sOAPArrayAbuseToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/SOAP-Array-Abuse");
        }


        private void sSIInjectionToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/SSI-Injection");
        }


        private void uRLRedictAbuseToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/URL-Redirector-Abuse");
        }


        private void xPathInjectionToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/XPath-Injection");
        }


        private void xMLAttributeBlowupToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/XML-Attribute-Blowup");
        }


        private void xMLExternalEntitiesToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/XML-External-Entities");
        }


        private void xMLEntitiesExpationsToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/XML-Entity-Expansion");
        }


        private void xMLInjectionToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/XML-Injection");
        }


        private void xQueryInjectionToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/XQuery-Injection");
        }


        private void applicationMisToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Application-Misconfiguration");
        }


        private void directoryIndexingToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Directory-Indexing");
        }


        private void improperFilesystemPermissionToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Improper-Filesystem-Permissions");
        }


        private void improperInputHandlingToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Improper-Input-Handling");
        }


        private void improperOutputHandlingToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Improper-Output-Handling");
        }


        private void informationLeakageToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Information-Leakage");
        }


        private void insecureIndexingToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Insecure-Indexing");
        }


        private void insufficientAutoToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Insufficient+Anti-automation");
        }


        private void insufficientAuthenticationToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Insufficient-Authentication");
        }


        private void insufficientAuthorizationToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Insufficient-Authorization");
        }


        private void insufficientPasswordRecoveryToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Insufficient-Password-Recovery");
        }


        private void insufficientProcessValidationToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Insufficient-Process-Validation");
        }


        private void insufficientSessionExpirationToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Insufficient-Session-Expiration");
        }


        private void insufficientTransportLayerProtectionToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Insufficient-Transport-Layer-Protection");
        }


        private void serverMisconfigurationToolStripMenuItem_Click(object sender, EventArgs e) {
            Process.Start("http://projects.webappsec.org/Server-Misconfiguration");
        }
        #endregion

        private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            About aboutForm = new About();
            aboutForm.MdiParent = this;
            aboutForm.Show();
            
        }
    }
}